<template>
  <div>
    <el-form ref="hotel" :model="hotel" label-width="80px" style="width:60%;margin-top:30px">
  <el-form-item label="酒店名称">
    <el-input v-model="hotel.hotelName"></el-input>
  </el-form-item>
  <el-form-item label="酒店星级">
    <el-select v-model="hotel.hotelLevel" placeholder="酒店星级">
           <el-option v-for="item in optionList" 
                          :key="item.id"
                          :value="item.id"
                          :label="item.name"> 
                  </el-option>
    </el-select>
  </el-form-item>
  <el-form-item label="创建时间">
    <el-col :span="11">
      <el-date-picker
      v-model="hotel.creationDate"
      type="datetime"
      placeholder="选择日期时间">
    </el-date-picker>
    </el-col>
  </el-form-item>
   <el-form-item label="所在城市">
    <el-input v-model="hotel.redundantCityName"></el-input>
  </el-form-item>
  <el-form-item label="酒店地址">
    <el-input type="textarea" v-model="hotel.address"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onSubmit">确认修改</el-button>
    <router-link to="/hotel/table" style="margin-left:20px">
    <el-button>取消</el-button>
    </router-link>
  </el-form-item>
</el-form>
  </div>
</template>

<script>
export default {
    data() {
      return {
        optionList:[
               {id:1,name:'经济型酒店'},
               {id:2,name:'二星级酒店'},
               {id:3,name:'三星级酒店'},
               {id:4,name:'四星级酒店'},
               {id:5,name:'五星级酒店'}
        ],
        hotel:{},
        url:"http://localhost:8080/bizhotel/itrip-hotel/",
      }
    },
    methods: {
      onSubmit() {
        this.$axios.put("http://localhost:8080/bizhotel/itrip-hotel/hotels",this.hotel).then(res=>{
            this.$router.push("/hotel/table");
        })
      }
    },
    created() {
        this.$axios.get(`http://localhost:8080/bizhotel/itrip-hotel/getHotel/${this.$route.params.id}`).then(res=>{
            this.hotel=res.data.data.hotel;
        })
    },
  }
</script>

<style>

</style>